package com.example.dc.Controller;

import com.example.dc.Service.Impl.ScoreServiceImpl;
import com.example.dc.Service.ScoreService;
import com.example.dc.domain.HealthScore;
import com.example.dc.utils.Result;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
        
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;

/**
 * @author curry
 * @version 1.0
 * Create by 2023/10/20 10:36
 */
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/score")
public class ScoreController {
    @Autowired
    private ScoreService scoreService;

    /**
     * 查询批判记录
     *
     * @return
     */
    @GetMapping("/health")
    public Result getAllQuestion(String startTime,
                                 String  endTime,
                                 Integer userId,
                                 Integer type,
                                 Integer orderBy) {
        log.info("传入的参数:" + startTime + "," + endTime + "," + userId + "," + type + "," + orderBy);
        List<HealthScore> healthScoreList = scoreService.getAllQuestion(userId, startTime, endTime, type, orderBy);
        return Result.success(healthScoreList);
    }

    @GetMapping("/health/{id}")
    public Result getHealthById(@PathVariable Integer id) {
        HealthScore healthScore = scoreService.getHealthById(id);
        return Result.success(healthScore);
    }

    @GetMapping("/health/sum")
    public Result sumScore(Integer userId) {
        System.out.println(userId);
        Double sum = scoreService.sumScore(userId);
        return Result.success(sum);
    }

    @GetMapping("/health/classify")
    public Result classifyScore(Integer userId){
        Map<String,Object> result=scoreService.classifyScore(userId);
        return Result.success(result);
    }

}
